package la.iok.hzsvn.lewin.movie.shopmovie.controller;

import la.iok.hzsvn.lewin.movie.core.Token;
import la.iok.hzsvn.lewin.movie.shopmovie.model.PlayerFeePayParam;
import la.iok.hzsvn.lewin.movie.shopmovie.service.CarpoolService;
import la.iok.hzsvn.share.response.OperatorResponse;
import la.iok.hzsvn.share.response.OperatorResponses;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("playerFees")
public class PlayerFeeController {
    private final CarpoolService carpoolService;

    public PlayerFeeController(CarpoolService carpoolService) {
        this.carpoolService = carpoolService;
    }

    /**
     * 玩家支付费用
     * @param token 操作用户
     * @param param 参数
     * @return 操作结果
     */
    @PutMapping("pay")
    public OperatorResponse confirmPay(@RequestHeader Token token, @RequestBody PlayerFeePayParam param){
        carpoolService.confirmPay(token, param);
        return OperatorResponses.success();
    }

    @DeleteMapping("{id}/payment")
    public OperatorResponse cancelPayment(@RequestHeader Token token, @PathVariable Long id, Long version){
        carpoolService.cancelPayment(token, id, version);
        return OperatorResponses.success();
    }

    @DeleteMapping("{id}")
    public OperatorResponse deleteFee(@RequestHeader Token token, @PathVariable Long id){
        carpoolService.deleteFee(token, id);
        return OperatorResponses.success();
    }
}
